import isArrayLike from '../util/isArrayLike'
import findIndex from './findIndex'
import findKey from '../object/findKey'

function find(obj, iteratee, context) {
  const keyFinder = isArrayLike(obj) ? findIndex : findKey
  const key = keyFinder(obj, iteratee, context)
  if (key !== undefined && key !== -1) {
    return obj[key]
  }
}

export default find
